//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System.ComponentModel;
using System.Workflow.ComponentModel;
using Microsoft.Research.ScientificWorkflow;

namespace TridentBasicActivities.Activities
{
    [Name("Activity for comapring two integers", "Integer Less than", "<")]
    [Description("Takes two int and returns TRUE if FIRST is less than SECOND.")]
    [WorkflowCategory("Condition")]
    public class CondIntLT : CondBase
    {
        public static System.Workflow.ComponentModel.DependencyProperty Input2Property =
            System.Workflow.ComponentModel.DependencyProperty.Register("Input2", typeof(int),
            typeof(CondIntLT));

        [RequiredInputParam]
        [Name("Input2")]
        [Description("Second Integer value for doing the comparison.")]
        public int Input2
        {
            get { return (int)GetValue(CondIntLT.Input2Property); }
            set { SetValue(CondIntLT.Input2Property, value); }
        }


        public static System.Workflow.ComponentModel.DependencyProperty Input1Property =
            System.Workflow.ComponentModel.DependencyProperty.Register("Input1", typeof(int),
            typeof(CondIntLT));

        [RequiredInputParam]
        [Name("Input1")]
        [Description("First Integer value for doing the comparison.")]
        public int Input1
        {
            get { return (int)GetValue(CondIntLT.Input1Property); }
            set { SetValue(CondIntLT.Input1Property, value); }
        }


        public static System.Workflow.ComponentModel.DependencyProperty ResultProperty =
            System.Workflow.ComponentModel.DependencyProperty.Register("Result", typeof(bool),
            typeof(CondIntLT));

        [OutputParam]
        [Name("Result")]
        [Description("Result of the greater than operation.")]
        public bool Result
        {
            get { return (bool)GetValue(CondIntLT.ResultProperty); }
            set { SetValue(CondIntLT.ResultProperty, value); }
        }

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.Result = (Input1 < Input2);
            return ActivityExecutionStatus.Closed;
        }
    }
}

